package com.example.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.daoman.Floor;
import com.example.daoman.User;
import com.example.mapper.FloorMapper;
import com.example.service.FloorService;
import com.example.utils.GetSession;
import com.example.utils.Message;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Component
public class FloorServiceImpl extends ServiceImpl<FloorMapper, Floor> implements FloorService {


    @Autowired
    FloorMapper floorMapper;

//    管理员查询自己所管理的楼层

    @Override
    public Message getUserFloorById() {
        List<Floor> userFloorById = floorMapper.getUserFloorById(GetSession.get().getId());
        return Message.out(200,"查询成功",userFloorById);
    }

    //    管理员查询自己所管理的楼层的房间的缴费情况

    @Override
    public Message getMyFloorApply(List<Floor> floorList) {
//        数据整合
        ArrayList<Integer> arrayList = new ArrayList<>();
        for (Floor f:floorList){
            arrayList.add(f.getId());
        }
        Map<String,Object> map = new HashMap<>();
        map.put("fidList",arrayList);
        List<Floor> myFloorApply = floorMapper.getMyFloorApply(map);
        return Message.out(200,"查询成功",myFloorApply);
    }
}
